package com.franklin.ideaplugin.easytesting.filetype;

import com.franklin.ideaplugin.easytesting.icon.PluginIcons;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.util.NlsContexts;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.nio.charset.StandardCharsets;

/**
 * @author Ye Junhui
 * @since 2023/7/26
 */
public class EasyTestingFormFileType implements FileType {

    public final static EasyTestingFormFileType INSTANCE = new EasyTestingFormFileType();

    @Override
    public @NonNls @NotNull String getName() {
        return "EasyTestingForm";
    }

    @Override
    public @NlsContexts.Label @NotNull String getDescription() {
        return "This is a file type for showing method execute form";
    }

    @Override
    public @NlsSafe @NotNull String getDefaultExtension() {
        return "form";
    }

    @Override
    public @Nullable Icon getIcon() {
        return PluginIcons.PLUGIN_ICON;
    }

    @Override
    public boolean isBinary() {
        //避免idea自带编辑器加载
        return false;
    }

    @Override
    public @NonNls @Nullable String getCharset(@NotNull VirtualFile file, byte @NotNull [] content) {
        return StandardCharsets.UTF_8.name();
    }
}
